Import('env')
testenv = env.Clone()

if not testenv.GetOption('clean'):

   def CheckRegex(context, re_type, re_header, re_lib = None):
      context.Message('Checking for ' + re_type + '... ')
      old_libs = None
      if(re_lib != None):
         old_libs = context.AppendLIBS(re_lib)
      result = context.TryLink("""
         #include """ + re_header + """
         """ + re_type + """ __re;
         int main() { return __re == __re; }
      """, '.cpp')
      context.Result(result)
      if(not result and old_libs != None):
         context.SetLIBS(old_libs)
      return result

   conf = Configure(testenv, custom_tests = {'CheckRegex': CheckRegex})
   if conf.CheckRegex('::std::regex', '<regex>'):
      conf.env.AppendUnique(CXXFLAGS = ['-DMOCKITOPP_STD_REGEX'])
   elif conf.CheckRegex('::std::tr1::regex', '<tr1/regex>'):
      conf.env.AppendUnique(CXXFLAGS = ['-DMOCKITOPP_STD_TR1_REGEX'])
   elif conf.CheckRegex('::boost::regex', '<boost/regex.hpp>', 'boost_regex'):
      conf.env.AppendUnique(CXXFLAGS = ['-DMOCKITOPP_BOOST_REGEX'])
   testenv = conf.Finish()

TEST_SRC = [
   'src/tpunit++main.cpp',
   # TODO: deprecate
   'src/TestArguments.cpp',
   'src/TestBasicStubbing.cpp',
#   'src/TestDefaultAction.cpp',
   'src/TestSimpleComposite.cpp',

   'src/test_iterator_style.cpp',
   'src/test_cref.cpp',
   'src/test_mfp_cv.cpp',
   'src/test_multiple_inheritance.cpp',
   'src/test_overloaded_functions.cpp',
   'src/test_verify.cpp',
   'src/bugs/issue_7.cpp',
   'src/bugs/issue_8.cpp',
   'src/compiler/alignment.cpp',
   'src/compiler/pointer_size.cpp',
   'src/matchers/test_any.cpp',
   'src/matchers/test_custom.cpp',
   'src/matchers/test_equal.cpp',
   'src/matchers/test_is_not.cpp',
   'src/matchers/test_null.cpp',
   'src/matchers/test_regex.cpp',
   'src/matchers/test_string_literal.cpp',
]
testenv.AppendUnique(CPPPATH = ['#include'])
testenv.AppendUnique(CPPPATH = ['src'])
test = testenv.Program('test', TEST_SRC)
unitTest = testenv.Test('test')

# vim:ft=python:
